const multer = require('koa-multer')
const { join } = require('path')

const storage = multer.diskStorage({
  // 存储位置
  destination: join(process.cwd(),"/public", "/avatar"),

  // 文件名
  filename(req, file, cb) {
    let filename = file.originalname.split(".")

    cb(null, `${Date.now()}.${filename.pop()}`)

  }
})

exports.save = multer({storage})
